package ar.edu.unq.wannaplay.utils;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;

import ar.edu.unq.wannaplay.dtos.EmployeeDTO;
import ar.edu.unq.wannaplay.services.EmployeeService;

public class EmployeeListView extends WPItemListView<EmployeeDTO, EmployeeService> {

    private static final long serialVersionUID = 1L;

    public EmployeeListView(final String id, final EmployeeService service, final List<String> labels, final Panel panel) {
        super(id, service, labels, service.findAllDTOs(), panel);
        this.setList(service.findAllDTOs());
    }

    @Override
    protected void addLinks(final ListItem<EmployeeDTO> item) {
        this.getUser().addEmployeesViewLinks(item, this, this.getPanel());
    }

    @Override
    protected void populateItem(final ListItem<EmployeeDTO> item) {
        EmployeeDTO employee = (EmployeeDTO) item.getDefaultModelObject();
        item.add(new Label("name", new PropertyModel<EmployeeDTO>(employee, "name")));
        item.add(new Label("surname", new PropertyModel<EmployeeDTO>(employee, "surname")));
        item.add(new Label("dni", new PropertyModel<EmployeeDTO>(employee, "dni")));
        item.add(new Label("telephone", new PropertyModel<EmployeeDTO>(employee, "telephone")));
        item.add(new Label("email", new PropertyModel<EmployeeDTO>(employee, "email")));
        this.addLinks(item);
    }
}
